package com.qianfeng.gl4study.youshare.view;

import com.qianfeng.gl4study.youshare.model.Category;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 数据存储区，单例访问
 * Created with IntelliJ IDEA.
 * I'm glad to share my knowledge with you all.
 * User:Gaolei
 * Date:2015/2/7
 * Email:pdsfgl@live.com
 */
public class DataStorage {
	private static DataStorage ourInstance;

	public static DataStorage getInstance() {
		if(ourInstance == null){
			ourInstance = new DataStorage();
		}
		return ourInstance;
	}

	//存储商城部分的分类信息
	private HashMap<String ,Category> storeCategories;


	private DataStorage() {
		storeCategories = new LinkedHashMap<String, Category>();
	}

	public void addCategory(Category category){
		if(category!=null){
			String cid = category.getId();
			if(cid!=null){
				storeCategories.put(cid,category);
			}
		}
	}
	public  Category getCategory(String cid){
		Category ret = null;
		if(storeCategories.containsKey(cid)){
			ret = storeCategories.get(cid);
		}
		return ret;
	}
}
